package gunfire.relics;

import basemod.abstracts.CustomRelic;
import com.badlogic.gdx.graphics.Texture;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.RelicAboveCreatureAction;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.powers.StrengthPower;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import gunfire.GunfireMod;
import gunfire.powers.ElementPower;
import gunfire.util.TextureLoader;

import static gunfire.GunfireMod.makeRelicOutlinePath;
import static gunfire.GunfireMod.makeRelicPath;

public class GlazedSight extends CustomRelic {

    public static final String ID = GunfireMod.makeID("GlazedSight");
    private static final Texture IMG = TextureLoader.getTexture(makeRelicPath("GlazedSight.png"));
    private static final Texture OUTLINE = TextureLoader.getTexture(makeRelicOutlinePath("blank.png"));

    public GlazedSight() {
        super(ID, IMG, OUTLINE, RelicTier.COMMON, LandingSound.CLINK);
        this.counter = 20;
    }

    @Override
    public void atBattleStart() {
        if(this.counter > 0){
            this.flash();
            this.addToBot(new RelicAboveCreatureAction(AbstractDungeon.player, this));
            int num = this.counter > 10 ? 2 : 1;
            this.addToBot(new ApplyPowerAction(AbstractDungeon.player, AbstractDungeon.player, new StrengthPower(AbstractDungeon.player, num), num));
            this.addToBot(new ApplyPowerAction(AbstractDungeon.player, AbstractDungeon.player, new ElementPower(AbstractDungeon.player, num), num));
        }
    }

    @Override
    public void wasHPLost(int damageAmount) {
        if(this.counter > 0){
            this.counter--;
            this.flash();
            if(this.counter <= 0){
                this.setCounter(-2);
            }
        }
    }

    @Override
    public void setCounter(int counter) {
        this.counter = counter;
        if (counter == -2) {
            this.usedUp();
            this.counter = -2;
        }
    }

    @Override
    public String getUpdatedDescription() {
        return DESCRIPTIONS[0];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new GlazedSight();
    }
}
